package com.esiea.contactmanager.model;

import java.util.ArrayList;
import java.util.List;


public class AdressBook {


    private List<Contact> contactList = new ArrayList<Contact>();
    private List<Integer> l = new ArrayList<Integer>();

	public List<Contact> getContactList() {
		return contactList;
	}

	public void setContactList(List<Contact> contactList) {
		this.contactList = contactList;
	}

	public void addContact(Contact a){
    	if(!contactList.contains(a))
    	{
    		contactList.add(a);
    		a.setId(contactList.indexOf(a));
    		
    	}
    }
    
    public void removeContact(Contact a){
    		contactList.remove(a);
    		for (Contact c: contactList) {
				c.setId(contactList.indexOf(c));
			}
    }
    
    public void removeContactById(int id)
    {   
    	
    	contactList.remove(id);
    }
    
    public Contact getContactById(int id){
    	return contactList.get(id);
    }
	
}
